﻿using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel;
using FollowMe.Infrastructure;

namespace FollowMe.Model
{
    public class Member : IAggregateRoot
    {
        [Key]
        public Guid MemberId { get; internal set; }

        [Required, Index(IsUnique = true), MaxLength(250)]
        public string UserName { get; internal set; }

        public string Email { get; internal set; }

        [Required, MaxLength(30), MinLength(1)]
        public string LastName { get; internal set; }

        [Required, MaxLength(30), MinLength(1)]
        public string FirstName { get; internal set; }

        [MaxLength(1), DefaultValue(" ")]
        public string MiddleInitial { get; internal set; }

        [DefaultValue(false)]
        public bool WillShareLocation { get; internal set; }

        //optionally virtual
        public IList<RegistrationID> RegistrationIDs { get; internal set; }

        public IList<Location> Locations { get; internal set; }

        /**
         * DO NOT MAKE VIRTUAL!!!
         * If these are lazy loaded, you may end up pulling the entire DB!
         * These will always be null!!!
         **/
        public IList<Friend> FriendsIAdded {  get; internal set; }

        public IList<Friend> FriendsThatAddedMe { get; internal set; }

        public IList<Message> MessagesSent { get; internal set; }

        public IList<Message> MessagesReceived { get; internal set; }


        public bool isThisMember(Member member)
        {
            return member.MemberId == this.MemberId;
        }

        protected virtual void Dispose(Boolean dis)
        {
            if (dis)
            {

            }
        }

        public void Dispose()
        {
            Dispose(true);
            GC.SuppressFinalize(this);
        }
    }
}
